#include <string>
#include <boost/bind.hpp>
#include <boost/function.hpp>
class Base
{
public:
	Base()
		: a(0)
	{}
	void fun()
	{
		auto f = [this]()
		{
			a = 100;
		};
		f();
		std::cout << __func__ << " " << a << std::endl;
	}
private:
	int a;
};
int main(int argc, char **argv)
{
	int a = 50;
	auto f = [=](int x, std::string& str)
	{
		//a = 100; //error: a is ready only
		str = std::to_string(x + a);
		return str;
	};
	std::string str;
	std::cout << f(100, str) << std::endl;
	std::cout << str << std::endl;
	std::cout << "a=" << a << std::endl;

	auto f1 = [&]()
	{
		a = 500;
	};
	f1();
	std::cout << "a=" << a << std::endl;
	
	Base b;
	b.fun();
	return 0;
}
